<template>
  <div>
    <div class="pvTop1">
      <router-link :to="{path:'/main/sitedetail'}">
        <div class="pvTop1_1">
          <van-icon name="arrow-left" />
        </div>
      </router-link>
      <div class="loadTop1_2"><img src="../assets/loadicon.png" alt="load"></div>
      <div class="pvTop1_3">{{$t('loadGenerator')}}</div>
    </div>
    <div class="pvBox">
      <div class="pvBox1">
        <div class="pvBox1_1">{{$t('TodayConsumption')}}</div>
        <div class="loadBox1_2">{{resData.todayConsumpiton | numFilter(1)}}kWh</div>
      </div>
      <div class="pvBox2">
        <div class="pvBox1_1">{{$t('ThisMonthConsumption')}}</div>
        <div class="loadBox1_2">{{resData.thisMonthConsumption | numFilter(1)}}kWh</div>
      </div>
      <div v-if='resData.meter2ComState != 0'>
        <div class="pvBox2">
          <div class="pvBox1_1">{{$t('LoadPower')}}</div>
          <div class="loadBox1_2">{{resData.load | numFilter(1)}}W</div>
        </div>
        <div class="pvBox2">
          <div class="pvBox1_1">{{$t('OtherGeneratorPower')}}</div>
          <div class="loadBox1_2">{{resData.power | numFilter(1)}}W</div>
        </div>
        <div class="pvBox2">
          <div class="pvBox1_1">{{$t('OtherGeneratorGeneration')}}</div>
          <div class="loadBox1_2">{{resData.generation | numFilter(1)}}kWh</div>
        </div>
        <div class="pvBox2">
          <div class="pvBox1_1">{{$t('OtherDeviceConsumption')}}</div>
          <div class="loadBox1_2">{{resData.consumption | numFilter(1)}}kWh</div>
        </div>
        </div>
    </div>
  </div>
</template>

<script>
import moment from 'moment'

export default {
  data(){
    return {
      resData:{}
    }
  },
  methods: {
    async getLoadData(){
      this.comm.loadingShow();
      let res = await this.API.getLoadData(localStorage.getItem("domain"),{
        'tokenId':localStorage.getItem("tokenId"),
        'siteId':localStorage.getItem('siteId'),
        'today':moment(new Date()).format('YYYY-MM-DD')
      })
      this.resData = res.result;
    }
  },
  mounted() {
    this.getLoadData();
  }
}
</script>

<style scoped lang="less">
.pvTop1{
  background: url("../assets/loadtop.png") no-repeat center  / 100% 100%;
  width: 100%;
  height: 150px;
  box-sizing: border-box;
}
.pvTop1_1{
  font-size: 30px;
  color: #FFFFFF;
  float: left;
  padding: 40px 16px 0 20px;
}
.loadTop1_2{
  float: left;
  padding-top: 34px;
  img{
    width: 40px;
  }
}
.pvTop1_3{
  font-size: 25px;
  font-weight: bolder;
  color: #FFFFFF;
  float: left;
  padding: 39px 0 0 10px;
}
.pvBox{
  position: absolute;
  top:95px;
  width: 100%;
  margin: 0 auto;
  padding:0 25px 10px 25px;
  box-sizing: border-box;
}
.pvBox1{
  height: 130px;
  width: 100%;
  background: url("../assets/kwh.png") no-repeat center / 100% 100%;
  border-radius: 5px;
  box-sizing: border-box;
}
.pvBox1_1{
  width: 100%;
  padding: 20px;
  color: #3B3D4E;
  font-size: 16px;
  text-align: left;
  box-sizing: border-box;
}
.loadBox1_2{
  width: 100%;
  padding: 10px 0 0 20px;
  font-size: 28px;
  color: #81699D;
  text-align: left;
  box-sizing: border-box;
}
.pvBox2{
  height: 130px;
  width: 100%;
  background: url("../assets/kwh.png") no-repeat center / 100% 100%;
  border-radius: 5px;
}
</style>
